<%@ page contentType="text/html;charset=utf-8"%>

<%@ page import="com.lovefreedom.psi.bean.*"%>
<%@ page import="java.util.List" %>
<%@ page import="com.lovefreedom.psi.dao.*" %>
<%@ page import="com.lovefreedom.psi.dao.impl.*" %>

<%
	
	List list = (List)request.getAttribute("categoryTree");

%>

<html>
<head>
<title>货品目录管理</title>
<link type="text/css" rel="stylesheet" href="../../scripts/ui/skins/Aqua/css/ligerui-all.css" />
<link type="text/css" rel="stylesheet" href="../images/style.css" />
<link type="text/css" rel="stylesheet" href="../../css/pagination.css" />
<script type="text/javascript" src="../../scripts/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../../scripts/ui/js/ligerBuild.min.js"></script>
<script type="text/javascript" src="../js/function.js"></script>

<script language="javascript">

//获取选中数量
function getCheckedCount()
{  
  	var count = 0;
  	for (var i=0; i < document.categoryform.length; i++)
  	{
    		if(document.categoryform.elements[i].checked) count++;
    	}
  	return count;
}
//进入编辑页面
function edit()
{
	var count = getCheckedCount();	
	if(count == 0)
	{
		//没有选中
		alert("请选中要修改的货品目录!");
		return;
	}
	else if(count > 1)
	{
		//选中了多个
		alert("最多只能选择一项");
		return;
	}
	else
	{		
    	//提交表单
		document.categoryform.action="update.jsp";
		document.categoryform.submit();  			
	}
	return;
}

//删除
function del()
{
 	if (getCheckedCount() == 0) 
 	{
    	alert("请选中要删除的货品目录!");
    	return;
  	}
  	if (confirm("有子目录的目录不能被删除，您确认要删除这些货品目录吗?")) 
  	{
    	//提交表单
		document.categoryform.action="delete.action";
		document.categoryform.submit();       		
  	}
}
</script>

</head>
<body class="mainbody">
<form method="post" name="categoryform">
    <div class="navigation">首页 &gt; 货品目录管理 &gt; 货品目录列表</div>
    <div class="tools_box">
	<div class="tools_bar">
	    <a href="add.jsp" class="tools_btn"><span><b class="add">添加货品目录</b></span></a>
	    <a href="#" class="tools_btn" onclick="edit()"><span><b class="edit">修改货品目录</b></span></a>
	    <a href="#" class="tools_btn" onclick="del()"><span><b class="delete">删除货品目录</b></span></a>
        </div>
    </div>

    <!--列表展示.开始-->

    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="msgtable">
      <tr>
        <th width="10%">选择</th>
        <th width="60%">目录名称</th>
        <th width="30%">目录级别</th>

      </tr>
<%
	Category category = new Category();
	for(int i = 0; i < list.size(); i++)
	{	
		category = (Category)list.get(i);  	
%>
      <tr>
        <td align="center"><input type="checkbox" name="categoryIds" value=<%=category.getId()%>></td>
        <td align="left"><span style=width:<%=category.getLevel()*18%>px;text-align:right;display:inline-block;></span><img src=../images/t.gif align=absmiddle /><img src=../images/folder_open.gif align=absmiddle /><%=category.getName()%></td>
        <td align="center"><%=category.getLevel()%></td>
      </tr>
<%
	}
%>      
	</table>
    <!--列表展示.结束-->
    
</form>
</body>
</html>

